package services.gyerpapi

import com.typesafe.config.Config
import play.api.ConfigLoader

case class GYCErpConfig(url:String="",appkey:String="",sessionkey:String="",secret:String="",targetAppKey:String="",qmAppKey:String,qmAppSecret:String)

object GYCErpConfig {
  implicit val configLoader:ConfigLoader[GYCErpConfig] = new ConfigLoader[GYCErpConfig] {
    override def load(config: Config, path: String): GYCErpConfig = {
      val conf = if (path.isEmpty){
        config.getConfig("gy.cerp.config.default")
      }else{
        config.getConfig("gy.cerp.config."+path)
      }
      GYCErpConfig(
        url = conf.getString("url"),
        appkey = conf.getString("appkey"),
        sessionkey = conf.getString("sessionkey"),
        secret = conf.getString("secret"),
        targetAppKey = conf.getString("targetAppKey"),
        qmAppKey = conf.getString("qmAppKey"),
        qmAppSecret = conf.getString("qmAppSecret")
      )
    }
  }
}
